<%@page import="org.apache.commons.lang3.time.DateFormatUtils"%>
<%@page import="com.us.usws.model.domain.system.User"%>
<%@page import="com.us.usws.biz.LoginOutWorker"%>
<%@page import="com.us.usws.model.domain.Meeting"%>
<%@page import="com.us.usws.service.ro.MeetingROService"%>
<%@page import="com.us.usws.common.SiteConstants"%>
<%@page import="com.us.usws.model.domain.video.Video"%>
<%@page import="com.us.usws.service.ro.VideoROService"%>
<%@page import="com.us.usws.model.flat.channel.DOChannel"%>
<%@page import="java.util.List"%>
<%@page import="com.us.usws.support.uitls.ServiceFactory"%>
<%@page import="com.us.usws.service.ro.ChannelROService"%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"	language="java"%>
<html>
<head>
<title>Site Navigation</title>
<script type="text/javascript" src="/ipodium-res/js/jquery-1.8.2.min.js"></script>
<style type="text/css">
body {
	font-family: Arial, Verdana, Geneva, Helvetica, sans-serif;
	font-size: 9pt;
}
input, select {
	font-family: Arial, Verdana, Geneva, Helvetica, sans-serif;
	font-size: 9pt;
	border: 1px solid #003366;
}
table {
	font-family: Arial, Verdana, Geneva, Helvetica, sans-serif;
	border: 0px;
	padding: 0px;
	font-size: 9pt;
	margin: 6px;
	border-collapse: collapse;
}

td,th {
	border: 0px;
	padding: 4px;
	empty-cells: show;
}

a:LINK,a:ACTIVE,a:VISITED {
	text-decoration: none;
	color: blue;
}

a:HOVER {
	text-decoration: overline underline;
	color: red;
}
</style>
<%
ChannelROService chS=ServiceFactory.getInstance().getService(ChannelROService.class);
VideoROService vS=ServiceFactory.getInstance().getService(VideoROService.class);
MeetingROService mS=ServiceFactory.getInstance().getService(MeetingROService.class);
List<DOChannel> topChannels=chS.getTopChannels();
List<Video> videos=vS.getAllVideos();
List<DOChannel> meetingChannels=chS.getTopChannelsByType(SiteConstants.DSID_CHANNEL_TYPE_MEETING);
List<DOChannel> videoChannels=chS.getTopChannelsByType(SiteConstants.DSID_CHANNEL_TYPE_VIDEO);
List<Meeting> allMeetings=mS.getAllMeetings();
User u=LoginOutWorker.getUserByEpIdentitiesAny(request);
%>
</head>
<body>
<table style="padding: 10px;border: 0;">
<tr valign="top">

<td style="border:0">
<fieldset>
<legend>终端资源JSon</legend>
<table>
	<tr>
		<td>
		<form action="/api/ebox/my_accounts/login.json" target="_blank" method="POST">
		<select name="login">
		<option value="1234567">学生</option>
		<option value="123456">家长</option>
		</select>
		/<input name="password" value="123456" type="text">
		<input type="submit" value="用户登录">
		</form>
		</td>
	</tr>
	<tr>
		<td><button onclick="submitLogout();">用户注销</button>&nbsp;&nbsp;<span id="logoutMsg" style="color:red"></span></td>
	</tr>
	<tr>
		<td style="border-top : 1px dashed gray;"></td>
	</tr>
	<tr>
		<td><a href="/api/ebox/index.json" target="_blank">终端首页</a></td>
	</tr>
	<tr>
		<td><a href="/api/ebox/my_channels.json" target="_blank">我的主频道</a></td>
	</tr>
	<tr>
		<td>二级频道列表
		<select name="schuid"><%
		for(DOChannel each:topChannels){%>
			<option value="<%=each.getUid()%>"><%=each.getName() %></option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/channels/'+document.getElementsByName('schuid')[0].value+'/sub_channels.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td>视频资源列表
		<select name="vlchuid"><%
		for(DOChannel each:topChannels){%>
			<option value="<%=each.getUid()%>"><%=each.getName() %></option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/channels/'+document.getElementsByName('vlchuid')[0].value+'/movies.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td>视频资源详细
		<select name="vuid"><%
		for(Video each:videos){%>
			<option value="<%=each.getUid()%>"><%=each.getName() %></option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/movies/'+document.getElementsByName('vuid')[0].value+'.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td>视频评分列表
		<select name="vcuid"><%
		for(Video each:videos){%>
			<option value="<%=each.getUid()%>"><%=each.getName() %></option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/movies/'+document.getElementsByName('vcuid')[0].value+'/comments.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td style="border-top : 1px dashed gray;"></td>
	</tr>
	<tr>
		<td><a href="/api/ebox/meetings.json" target="_blank">会议列表</a></td>
	</tr>
	<tr>
		<td>频道会议列表
		<select name="mtcuid"><%
		for(DOChannel each:meetingChannels){%>
			<option value="<%=each.getUid()%>"><%=each.getName() %></option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/channels/'+document.getElementsByName('mtcuid')[0].value+'/meetings.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td>会议详情
		<select name="mtcuid"><%
		for(Meeting each:allMeetings){%>
			<option value="<%=each.getUid()%>"><%=each.getTitle() %> (<%=each.getConfRoomId() %>)</option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/channels/'+document.getElementsByName('mtcuid')[0].value+'/meetings.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td style="border-top : 1px dashed gray;"></td>
	</tr>
	<tr>
		<td><a href="/api/ebox/channels/p_student_channels.json" target="_blank">学生主界面</a></td>
	</tr>
	<tr>
		<td><a href="/api/ebox/themes.json" target="_blank">主题首页</a></td>
	</tr>
	<tr>
		<td>主题详情
		<select name="themeuid"><%
		for(Meeting each:allMeetings){%>
			<option value="<%=each.getUid()%>"><%=each.getTitle() %> (<%=each.getConfRoomId() %>)</option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/themes/'+document.getElementsByName('themeuid')[0].value+'.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td>学生二级频道列表
		<select name="stuschuid"><%
		for(DOChannel each:topChannels){%>
			<option value="<%=each.getUid()%>"><%=each.getName() %></option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/channels/'+document.getElementsByName('stuschuid')[0].value+'/two_student_channels.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td>学生会议列表
		<select name="stumtcuid"><%
		for(DOChannel each:meetingChannels){%>
			<option value="<%=each.getUid()%>"><%=each.getName() %></option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/channels/'+document.getElementsByName('stumtcuid')[0].value+'/stu_meetings.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td>学生频道视频列表
		<select name="stumtcuid"><%
		for(DOChannel each:videoChannels){%>
			<option value="<%=each.getUid()%>"><%=each.getName() %></option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/channels/'+document.getElementsByName('stumtcuid')[0].value+'/activity.json');">Go</button>
		</td>
	</tr>
	<tr>
		<td>我要报名
		<select name="appvuid"><%
		for(Video each:videos){%>
			<option value="<%=each.getUid()%>"><%=each.getName() %></option><%
		}
		%>
		</select>
		<button onclick="window.open('/api/ebox/channels/applicant.json?movie_id='+document.getElementsByName('appvuid')[0].value);">Go</button>
		</td>
	</tr>
</table>
</fieldset>
</td>

<td>&nbsp;&nbsp;&nbsp;</td>

<td>
<table>
<tr><td>
<fieldset>
<legend>终端用户激活JSon</legend>
<table>
	<tr>
	<form action="/api/ebox/authcodes.json" method="POST" target="_blank">
		<td>手机号：</td><td><input type="text" name="mobile" value="" size="11"></td>
		<td colspan="5"><input type="submit" value="获取验证码（忘记密码）"></td>
	</form>
	</tr>
	<tr>
	<form action="/api/ebox/authcodes/create_code.json" method="POST" target="_blank">
		<td>手机号：</td><td><input type="text" name="mobile" value="" size="11"></td>
		<td colspan="5"><input type="submit" value="获取验证码（激活密码）"></td>
	</form>
	</tr>
	<tr>
	<form action="/api/ebox/authcodes/check.json" method="POST" target="_blank">
		<td>手机号：</td><td><input type="text" name="mobile" value="" size="11"></td>
		<td>验证码：</td><td><input type="text" name="authcode" value="" size="11"></td>
		<td colspan="3"><input type="submit" value="验证验证码"></td>
	</form>
	</tr>
	<tr>
		<td style="border-top : 1px dashed gray;" colspan="7"></td>
	</tr>
	<tr>
		<td>密码：</td><td><input type="text" name="password" value="" size="11"></td>
		<td>确认密码：</td><td><input type="text" name="password_confirmation" value="" size="11"></td>
		<td>旧密码：</td><td><input type="text" name="old_password" value="" size="11"></td>
		<td><button onclick="submitParentPass();">家长密码重置</button></td>
	</tr>
	<tr><td colspan="7"><span id="parentUpdmsg" style="color:red"></span></td></tr>

</table>
</fieldset>
</td></tr>
<tr><td>
<fieldset>
<legend>终端管理中心JSon</legend>
<table>
	<tr>
		<td><a href="/api/ebox/my_operations/last_events.json" target="_blank">功能说明</a></td>
	</tr>
	<tr>
		<td><a href="/api/ebox/my_accounts/profile.json" target="_blank">个人资料</a></td>
	</tr><%
	if(u!=null){%>
	<tr>
		<td>
		<fieldset>
		<legend>更新个人资料</legend>
		<table>
			<tr>
				<td>登录名：</td><td><input type="text" name="login" value="<%=u.getLoginName() %>" size="10"></td>
				<td>姓名：</td><td><input type="text" name="Name" value="<%=u.getFullName() %>" size="10"></td>
				<td>性别：</td><td><select name="Sex"><option value="M" <%="M".equals(u.getGenderType())?"checked":"" %>>男</option><option value="F" <%="M".equals(u.getGenderType())?"":"checked" %>>女</option></select></td>
				<td>生日：</td><td><input type="text" name="birthday" value="<%=u.getUserAttr()==null?"":(u.getUserAttr().getBirthDate()==null?"":DateFormatUtils.format(u.getUserAttr().getBirthDate(), "yyyy-MM-dd")) %>" size="10" maxlength="10"></td>
			</tr>
			<tr><td colspan="8"><button onclick="submitUpdProfile();">提交</button></td></tr>
			<tr><td colspan="8"><span id="updmsg" style="color:red"></span></td></tr>
		</table>
		</fieldset>
		</td>
	</tr><%
	}%>
</table>
</fieldset>
</td></tr>
</table>
</td>
<td>&nbsp;&nbsp;&nbsp;</td>

<td>
<fieldset>
<legend>快捷链接</legend>
<table  cellpadding="5" cellspacing="0" border="0">
<tr><td><a href="/index.action" target="_blank">首页</a></td></tr>
<tr><td><a href="/ipodium/index.action" target="_blank">老师PC端</a></td></tr>
<tr><td style="border-top : 1px dashed gray;"></td></tr>
<tr><td><a href="/config-browser/actionNames.action" target="_blank">Struts2配置查看</a></td></tr>
<tr><td><a href="/siteInit?act=refresh" target="_blank">重新加载配置文件</a></td></tr>
<tr><td><a href="/system/cache_manager.jsp" target="_blank">缓存管理</a></td></tr>
<tr><td><a href="/batch_res_imp.jsp" target="_blank">批量导入</a></td></tr>
</table>
</fieldset>
</td>
</tr>
</table>
<script type="text/javascript">
function submitUpdProfile(){
$.ajax({
	url: '/api/ebox/my_accounts/update_profile.json',
	type: 'PUT',
		success: function(response) {
			$("#updmsg").text(response);
		},
		error: function(){
			$("#updmsg").text("Error!");
		}
	});
}

function submitParentPass(){
	$.ajax({
		url: '/api/ebox/my_accounts/pass_update.json',
		type: 'PUT',
			success: function(response) {
				$("#parentUpdmsg").text(response);
			},
			error: function(){
				$("#parentUpdmsg").text("Error!");
			}
		});
}
function submitLogout(){
	$.ajax({
		url: '/api/ebox/my_accounts/logout.json',
		type: 'PUT',
		contentType: "application/json; charset=utf-8",
			success: function(response) {
				$("#logoutMsg").text(response);
			},
			error: function(){
				$("#logoutMsg").text("Error!");
			}
		});	
}
</script>
</body>
</html>